<%-- 
    Document   : exam
    Author     : Jalbs
--%>

<code>
       <style type="text/css" title="currentStyle">
           @import "../css/ui-lightness/jquery-ui-1.7.2.custom.css";
           @import "../css/table/css/demo_table_jui.css";
           @import "../css/jquery.alerts.css";
        </style>
        <script type="text/javascript" language="javascript" src="../js/jquery-1.3.2.js"></script>
        <script type="text/javascript" language="javascript" src="../js/jquery.dataTables.js"></script>
        <script type="text/javascript" language="javascript" src="../js/jquery-ui-1.7.2.custom.min.js"></script>
        <script src="../js/jquery.alerts.js" type="text/javascript"></script>

        <script type="text/javascript" charset="utf-8">
            $(document).ready(function() {
                         var action;
                         var asInitVals = new Array();
                          $("#formDialog").dialog({
                            bgiframe: true,
                            autoOpen: false,
                            width:340,
                            height: 420,
                            modal: true,
                            buttons: {
                                    'Aceptar': function() {
                                       $("#subjectKey").removeAttr("disabled");
                                       $("#studentKey").removeAttr("disabled");
                                       $("#ID_Professor").removeAttr("disabled");
                                       $("#dates").removeAttr("disabled");
                                       $("#examType").removeAttr("disabled");
                                       $("#id_cur").removeAttr("disabled");
                                       var valuesExam=$("#modifyExamForm").serialize();
                                       if(action=="m"){
                                            $.post("modifyExam.do", valuesExam, function(response){
                                                if(response=="success"){
                                                    var ID_Exam=$("#ID_Exam").val();
                                                    $("#examGrade_"+ID_Exam).html($("#examGrade").val());
                                                    jAlert("Se modifico el Examen exitosamente", "Examen")
                                                }else   jAlert(response, "Error");
                                            }, "html");
                                        }

                                        $(this).dialog('close');
                                    },
                                    Cancel: function() {
                                            $(this).dialog('close');
                                    }
                            }
                        });
                        
                        $("#examInform").click(function(){
                                arrayCheckBox = new Array;
                                $("input:checked").each(function(id) {
                                myVar = $("input:checked").get(id);
                                arrayCheckBox.push(myVar.value);
                                });
                            $.post("getExamInform.do",{id:arrayCheckBox}, function(response){
                                
                            });
                        });


                        $("a[href=#modify]").click(function(){
                            var id_student=$(this).attr("id");
                            action="m";
                             $.post("getExamToModify.do",{id:id_student},function(page){
                                $('#formDialog').html(page);
                                $('#formDialog').dialog('open');
                            }, "html");
                        });                                                



                        $("tfoot input").keyup( function () {
                                oTable.fnFilter( this.value, $("tfoot input").index(this) );
                        } );

                        $("tfoot input").each( function (i) {
                                asInitVals[i] = this.value;
                        } );

                        $("tfoot input").focus( function () {
                                if ( this.className == "search_init" )
                                {
                                        this.className = "";
                                        this.value = "";
                                }
                        } );

                        $("tfoot input").blur( function (i) {
                                if ( this.value == "" )
                                {
                                        this.className = "search_init";
                                        this.value = asInitVals[$("tfoot input").index(this)];
                                }
                        } );

                       oTable = $('#examList').dataTable({
					"bJQueryUI": true,
					"sPaginationType": "full_numbers",
                                        "aoColumns": [
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                            null,
                                           { "bSortable": false },
                                           { "bSortable": false },

                                        ]
				});

            } );



		</script>

</code>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<logic:present name="completeGradeList">

<bean:size id="size" name="completeGradeList"/>
<logic:greaterThan name="size" value="0">

<div class="demo_jui">    
    <table width="800px" cellpadding="0" cellspacing="0" border="0" class="display" id="examList">
        <thead>
            <tr >
                <th>ID</th>
                <th>Calificacion</th>
                <th>Tipo</th>
                <th>Materia</th>
                <th>Alumno</th>
                <th>Profesor</th>
                <th>Clave del Plan</th>
                <th>Fecha</th>
                <th>Clave de solicitud</th>
                <th>Operacion</th>
                <th><html:link href="#" styleId="examInform">Actas de examen</html:link></th>
            </tr>
        </thead>
        <tbody id="tableBody">
            <logic:iterate id="result" name="completeGradeList">
                <tr class="gradeU" id="row_${result.ID_Exam}">
                    <td id="id_${result.ID_Exam}"><bean:write name="result" property="ID_Exam" /></td>
                    <td id="examGrade_${result.ID_Exam}"><bean:write name="result" property="examGrade" /></td>
                    <td><bean:write name="result" property="examType" /></td>
                    <td><bean:write name="result" property="subjectName" /></td>
                    <td><bean:write name="result" property="studentName" /></td>
                    <td><bean:write name="result" property="profName" /></td>
                    <td><bean:write name="result" property="ID_Curriculum" /></td>
                    <td><bean:write name="result" property="dates" /></td>
                    <td><bean:write name="result" property="ID_Request" /></td>                   
                    <td><center><html:link href="#modify" styleId="${result.ID_Exam}" ><bean:message key="label.button.modify"/></html:link></center></td>
                    <td><center><html:checkbox property="checked" name="result"></html:checkbox></center></td>
                </tr>
            </logic:iterate>
        </tbody>
        <tfoot>
            <tr>
                <th>ID</th>
                <th>Calificacion</th>
                <th>Tipo</th>
                <th>Materia</th>
                <th>Alumno</th>
                <th>Profesor</th>
                <th>Clave del Plan</th>
                <th>Fecha</th>
                <th>Clave de solicitud</th>
                <th>Operacion</th>
                <th><html:link href="#" styleId="examInform">Actas de examen</html:link></th>
            </tr>
            <tr>
                <td><input type="text" name="search_np" value="ID" class="search_init" /></td>
                <td><input type="text" name="search_np" value="Calificacion" class="search_init" /></td>
                <td><input type="text" name="search_np" value="Tipo" class="search_init" /></td>
                <td><input type="text" name="search_np" value="Materia" class="search_init" /></td>
                <td><input type="text" name="search_np" value="Alumno" class="search_init" /></td>
                <td><input type="text" name="search_np" value="Profesor" class="search_init" /></td>
                <td><input type="text" name="search_np" value="Plan de estudio" class="search_init" /></td>
                <td><input type="text" name="search_np" value="Fecha" class="search_init" /></td>
                <td><input type="text" name="search_np" value="Clave de solicitud" class="search_init" /></td>
                <td></td>
            </tr>
        </tfoot>
    </table>
</div>
</logic:greaterThan>
</logic:present>


<div id="formDialog">

</div>